//
//  HMScoreLiveViewController.m
//  01-网易彩票
//
//  Created by SZSYKT_iOSBasic_2 on 16/2/20.
//  Copyright © 2016年 heima. All rights reserved.
//

#import "HMScoreLiveViewController.h"
#import "HMDatePicker.h"

@interface HMScoreLiveViewController() <HMDatePickerDelegate>

@end

@implementation HMScoreLiveViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // 创建1个组模型
    // 创建第1组
    HMSettingItem *item11 = [HMSettingItemSwitch itemWithTitle:@"推送我关注的比赛"];
    HMSettingGroup *group1 = [HMSettingGroup groupWithItems:@[item11]];
    group1.footer = @"发发阿萨德发送到阿萨德撒的十大撒的大是大非安抚阿斯蒂芬安抚阿斯蒂芬撒地方撒地方阿萨德";
    
    HMSettingItemLabel *startTime = [HMSettingItemLabel itemWithTitle:@"起始时间" defaultValue:@"00:00"];
    HMSettingItemLabel *endTime = [HMSettingItemLabel itemWithTitle:@"结束时间" defaultValue:@"12:00"];
    
    startTime.operationBlock = ^ {
        // 创建日期选择器
        HMDatePicker *pickerView = [HMDatePicker datePicker];
        // 设置最大的选择时间
        pickerView.datePicker.maximumDate = [NSDate dateFromString:endTime.text format:@"HH:mm"];        
        // 设置datePicker当前显示的时间
        pickerView.currentDate = [NSDate dateFromString:startTime.text format:@"HH:mm"];
        
        // 设置代理
        pickerView.delegate = self;
        // 设置focusObject
        pickerView.focusObject = startTime;
        // 显示
        [pickerView show];
    };
    HMSettingGroup *group2 = [HMSettingGroup groupWithItems:@[startTime]];
    group2.header = @"涅米你发送到发安抚阿双方都是阿发发发送到发发送到萨芬撒的发送到阿发";
    
    
    endTime.operationBlock = ^ {
        // 创建日期选择器
        HMDatePicker *pickerView = [HMDatePicker datePicker];
        // 设置最小的选择时间
        pickerView.datePicker.minimumDate = [NSDate dateFromString:startTime.text format:@"HH:mm"];
        // 设置datePicker当前显示的时间
        pickerView.currentDate = [NSDate dateFromString:endTime.text format:@"HH:mm"];
        // 设置代理
        pickerView.delegate = self;
        // 设置focusObject
        pickerView.focusObject = endTime;
        // 显示
        [pickerView show];
    };
    
    HMSettingGroup *group3 = [HMSettingGroup groupWithItems:@[endTime]];
    // 将组模型添加到数组中
    self.groups = [NSMutableArray arrayWithObjects:group1,group2,group3,nil];
}


#pragma mark - HMDatePickerDelegate 代理方法
- (void)datePickerDidValueChanged:(HMDatePicker *)dateP {
    HMSettingItemLabel *itemLabel = (HMSettingItemLabel *) dateP.focusObject;
    itemLabel.text = [dateP.datePicker.date stringFromDateFormat:@"HH:mm"];
    // 刷新表格
    [self.tableView reloadData];
}


@end
